package com.manage.platform.controller;

import com.manage.platform.dto.DictDto;
import com.manage.platform.dto.query.DictPageQuery;
import com.manage.platform.service.impl.DictServiceImpl;
import com.manage.platform.utils.R;
import com.manage.platform.utils.RPage;
import com.manage.platform.vo.DictPartVo;
import com.manage.platform.vo.DictVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * YWD
 * 2025/9/19
 */
@AllArgsConstructor
@RestController
@RequestMapping("/dict")
@Tag(name = "系统设置-字典管理")
public class DictController {

    private final DictServiceImpl dictService;

    @PostMapping("/getDictPage")
    @Operation(summary = "查询字典列表(分页)")
    public R<RPage<List<DictVo>>> getDictPage(@RequestBody DictPageQuery query) {
        return R.ok(dictService.getDictPage(query));
    }

    @GetMapping("/getDictDetails/{id}")
    @Operation(summary = "查询字典详情")
    public R<DictVo> getDictDetails(@Schema(description = "ID") @PathVariable("id") Long id) {
        return R.ok(dictService.getDictDetails(id));
    }

    @PostMapping("/saveDict")
    @Operation(summary = "添加字典")
    public R<Boolean> saveDict(@RequestBody DictDto dto) {
        return R.ok(dictService.saveDict(dto));
    }

    @PutMapping("/updateDict")
    @Operation(summary = "修改字典")
    public R<Boolean> updateDict(@RequestBody DictDto dto) {
        return R.ok(dictService.updateDict(dto));
    }

    @DeleteMapping("/deleteDict/{id}")
    @Operation(summary = "删除字典")
    public R<Boolean> deleteDict(@Schema(description = "ID") @PathVariable("id") Long id) {
        return R.ok(dictService.deleteDict(id));
    }


}
